package com.ruoyi.system.vis.service.impl;

import com.ruoyi.system.domain.SysCheck;
import com.ruoyi.system.mapper.SysCheckMapper;
import com.ruoyi.system.vis.domain.VisPreCheck;
import com.ruoyi.system.vis.mapper.VisPreCheckMapper;
import com.ruoyi.system.vis.service.VisPerCheckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class VisPerCheckServiceImpl implements VisPerCheckService {
    @Autowired
    private VisPreCheckMapper visPreCheckMapper;
    @Autowired
    private SysCheckMapper sysCheckMapper;
    @Override
    public int add(Long patientId,Long[] checkIds) {
        int count=0;
        for (Long checkId : checkIds) {
            visPreCheckMapper.addCheck(patientId,checkId);
            count++;
        }
       return count;
    }

    @Override
    public List<SysCheck> selectCheckByPatientId(Long patientId) {
        List<SysCheck> list = new ArrayList<>();
        long[] ids = visPreCheckMapper.selectByPatientId(patientId);
        for (long checkId : ids) {
            SysCheck sysCheck = sysCheckMapper.selectCheckById(checkId);
            list.add(sysCheck);
        }
        return list;
    }

    @Override
    public int confirmCheck(long patientId) {
        return visPreCheckMapper.confirmCheck(patientId);
    }
}
